/*!
 * 文库 通用（请求）方法
 *  
 * 作者：张莉
 * Copyright (c) 2019/12/05
 * 
 */

/**
 * @method orgRoot 组织树父级接口
 * @return axios
 */
export const orgRoot = () => {
  return axios({
    url: '/org/organization/root',
    method: 'get'
  })
}
/**
 * @method orgParent 组织树子级接口
 * @param {string} id 父级机构的orgId
 * @return axios
 */
export const orgParent = (id) => {
  return axios({
    url: `/org/organization/parent/${id}`,
    method: 'get',
  })
}
/**
 * @method orgSearch 组织树搜索接口
 * @param {string} id 模糊搜索值orgName
 * @return axios
 */
export const orgSearch = (val) => {
  return axios({
    url: '/org/organization/search?orgName=' + val,
    method: 'get',
  })
}
/**
 * @method findDocLibCatList 文库分类列表
 * @return axios
 */
export const findDocLibCatList = () => {
	return axios({
    url: '/doclibrary/docLibCat/findDocLibCatList',
    method: 'post',
  })
}
/**
 * @method findDocLibraryList 文档列表
 * @param {number} page 文库表格当前显示的页数
 * @param {number} size 文库表格一页有多少条数据
 * @param {object} data 存放搜索表格文件名或者textSearch作者对象
 * @return axios
 */
export const findDocLibraryList = (page, size, type, data) => {
  return axios({
    url: `/doclibrary/findDocLibraryList/${page}/${size}?type=` + type,
    method: 'post',
    data
  })
}
/**
 * @method findDocLibraryInsert 新增文件夹
 * @param {object} data 文件名称libDocName,文件libCatId,文件类型libDocType,上层upDocId,组织orgId,项目projectId
 * @return axios
 */
export const findDocLibraryInsert = (data, type) => {
  return axios({
    url: '/doclibrary/insert?type=' + type,
    method: 'post',
    data
  })
}
/**
 * @method findDocLibraryDelete 根据ID删除文件或文件夹
 * @param {string} libDocId 当前文件libDocId
 * @return axios
 */
export const findDocLibraryDelete = (libDocId, type) => {
  return axios({
    url: `/doclibrary/delete/${libDocId}?type=` + type,
    method: 'delete'
  })
}
/**
 * @method findDocLibraryPreview 根据文件id 预览 返回预览文件地址
 * @param {string} libDocId 当前文件libDocId
 * @return axios
 */
export const findDocLibraryPreview = (libDocId, type) => {
  return axios({
    url: `/doclibrary/preview/${libDocId}?type=` + type,
    method: 'get'
  })
}
/**
 * @method findDocLibraryUpdate 修改文件夹
 * @param {object} data 文件名称libDocName,文件libCatId,文件类型libDocType,上层upDocId,组织orgId,项目projectId
 * @return axios
 */
export const findDocLibraryUpdate = (data, type) => {
  return axios({
    url: '/doclibrary/update?type=' + type,
    method: 'put',
    data
  })
}
/**
 * @method findDocLibraryCopy 复制
 * @param {object} data 文件名称libDocName,文件libCatId,文件类型libDocType,上层upDocId,组织orgId,项目projectId
 * @return axios
 */
export const findDocLibraryCopy = (data, type) => {
  return axios({
    url: '/doclibrary/copy?type=' + type,
    method: 'post',
    data
  })
}
/**
 * @method findDocLibraryMove 移动
 * @param {object} data 文件名称libDocName,文件libCatId,文件类型libDocType,上层upDocId,组织orgId,项目projectId
 * @return axios
 */
export const findDocLibraryMove = (data, type) => {
  return axios({
    url: '/doclibrary/move?type=' + type,
    method: 'post',
    data
  })
}